{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import time\n",
    "import psutil\n",
    "from pprint import pprint"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## CPU"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[scputimes(user=2125.109375, system=5115.703125, idle=216734.53125, interrupt=550.421875, dpc=365.703125),\n",
       " scputimes(user=1499.0625, system=2242.031249999971, idle=220233.40625, interrupt=15.046875, dpc=14.0625),\n",
       " scputimes(user=2838.15625, system=5336.624999999971, idle=215799.71875, interrupt=28.53125, dpc=44.984375),\n",
       " scputimes(user=2185.890625, system=3569.953125000029, idle=218218.65624999997, interrupt=17.40625, dpc=29.734375),\n",
       " scputimes(user=2095.53125, system=3553.468750000029, idle=218325.49999999997, interrupt=18.5625, dpc=70.59375),\n",
       " scputimes(user=1960.703125, system=4696.8125, idle=217316.96875, interrupt=11.109375, dpc=8.375),\n",
       " scputimes(user=2693.515625, system=4938.578125000029, idle=216342.39062499997, interrupt=18.65625, dpc=100.25),\n",
       " scputimes(user=2675.90625, system=3975.578125, idle=217323.0, interrupt=9.703125, dpc=8.203125)]"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 每个cpu的时间，返回的是个namedtuple 列表。\n",
    "psutil.cpu_times(percpu=True)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
